//
//  InstructTools.m
//  RtspClient
//
//  Created by qi tan on 2024/1/9.
//  Copyright © 2024 Andres Rojas. All rights reserved.
//

#import "InstructTools.h"

@implementation InstructTools

+ (NSString *)buildRtspSetInstruct:(NSString *)domain
                         andSubUrl:(NSString *)subUrl
                      andParamDict:(NSMutableDictionary *)dict{
    NSMutableString * mutableStr = [NSMutableString string];
    [mutableStr setString:domain];
    [mutableStr appendString:subUrl];
    if(![subUrl hasSuffix:@"?"]){
        [mutableStr appendString:@"?"];
    }
    [dict enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        [mutableStr appendFormat:@"-%@=%@&", key, obj];
    }];
    NSRange range = NSMakeRange(mutableStr.length -1, 1);
    [mutableStr deleteCharactersInRange:range]; // 删除最后的&符号。
    
    return mutableStr;
}


@end
